package com.fatgirl.interactive.radio
{

	/**
	 * 单选管理器 
	 * @author iceman
	 * 
	 */
	public class RadioGroup
	{
		
		private static var s_SingleSelectManagerArr:Array = new Array;
		
		private var m_singleSelect:IRadio;
		public function RadioGroup(_name:String):void
		{
			if(s_SingleSelectManagerArr[_name]) throwError(this,FatError.SINGLETON_CLASS);
		}
		/**
		 * 通过名字获取一个单选组的实例 
		 * @param _name
		 * @return 
		 * 
		 */
		public static function getInstance(_name:String):RadioGroup
		{
			if(s_SingleSelectManagerArr[_name])
				return s_SingleSelectManagerArr[_name] as RadioGroup;
			return s_SingleSelectManagerArr[_name] = new RadioGroup(_name);
		}
		/**
		 * 根据组进行设置单选状态
		 * 传递不为ISingleSelect类型  则选择空
		 * @param _singleSelectObj 实例
		 * @param _selectGroupID  组ID
		 * 
		 */
		public function select(_singleSelectObj:IRadio):void
		{
			if(m_singleSelect) m_singleSelect.selected = false;
			if(!_singleSelectObj) return;
			_singleSelectObj.selected = true;
			m_singleSelect = _singleSelectObj;
		}
	}
}